package com.shop.cereshop.business.controller;


import com.shop.cereshop.business.service.shop.CereShopSkuNameService;
import com.shop.cereshop.business.service.shop.CereShopSkuService;
import com.shop.cereshop.commons.constant.CoReturnFormat;
import com.shop.cereshop.commons.domain.shop.CereShopSku;
import com.shop.cereshop.commons.domain.shop.CereShopSkuName;
import com.shop.cereshop.commons.domain.shop.bo.CereShopSkuBo;
import com.shop.cereshop.commons.domain.shop.bo.CereShopSkuNameBo;
import com.shop.cereshop.commons.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/shop/skuName")
/**
 * 注解方式生成日志对象，指定topic生成对象类名
 */
@Slf4j(topic = "CereShopSkuNameController")
@Api(value = "店铺规格值模块", tags = "店铺规格值模块")
public class CereShopSkuNameController {

    @Autowired
    private CereShopSkuNameService cereShopSkuNameService;


    @GetMapping("/queryList")
    @ApiOperation(value = "查询规格值")
    public Result<?> queryList(CereShopSkuNameBo bo, HttpServletRequest request){
        return new Result<>(cereShopSkuNameService.queryList(bo), CoReturnFormat.SUCCESS);
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加规格值")
    public Result<?> add(@RequestBody CereShopSkuName cereShopSkuName, HttpServletRequest request){
        return new Result<>(cereShopSkuNameService.save(cereShopSkuName), CoReturnFormat.SUCCESS);
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改规格值")
    public Result<?> update(@RequestBody CereShopSkuName cereShopSkuName, HttpServletRequest request){
        return new Result<>(cereShopSkuNameService.updateById(cereShopSkuName), CoReturnFormat.SUCCESS);
    }
    @GetMapping("/remove")
    @ApiOperation(value = "删除规格值")
    public Result<?> remove(Long id, HttpServletRequest request){
        return new Result<>(cereShopSkuNameService.removeById(id), CoReturnFormat.SUCCESS);
    }

}
